Repository navigation
feat!: retire event types and personal-data categories, and redact by envelope - #384
Open
benatespina wants to merge 33 commits into
Open
benatespina wants to merge 33 commits into
benatespina wants to merge 33 commits into
Conversation
…y start records Squashed from the PR 2 sessions so far, to rebase onto the merged PR 1: - feat(core): retire event types, refuse types no module names and reach a retired event's process - feat(cli): generate retired event types - feat(core): export and redact a retired event type's personal data by its envelopes - test(core): close every connection before restoring a SQLite backup in the retired personal data tests - feat(core): record event type marks, the kinds that opened a stream and each process letter's instance - test(core): restore the marks and the kinds that opened a stream with a copy, and migrate a SQLite copy taken before them - feat(core): seal retired event types by the marks every start records - fix(core): never write back in the clear what an upcast carries or makes from a sealed value under a key no schema declares - test(core): seal retired types end to end across rolling deploys, A to B to A marks, frozen and forgotten tenants - test(core): refuse a rebuild and a ledger prune over a retired type no start recorded marks for
… E32's refusals for every kind they list
… it has no module for
… other marks see it run A held walk returned before taking the lease, which then lapsed: an instance on other marks read these as stopped, rewrote events in a shape they may not read, called itself caught up and removed their rows, the hold included. The held instance now passes every follow interval to renew the lease, and nextDueAt still waits for the hold's end.
…f marks bounda_event_marks gains sealed_through, in the unreleased migration. EventStore.recordSealed raises it on the sets given and clears it on the type's other sets sealed no further, so the set sealed last holds the highest: monotone, fenced and staged in transactions like recordMarks, on memory, SQLite and PostgreSQL.
…ast sealed under alone A backfill walk that catches up with no instance on other marks running records its sets sealed through its position. StoredMarks.authority names the type's set sealed last, and retiredMarksOf takes a field's category from it when it marks the field for the event's person, or else from the one category every own set gives, leaving the field in the clear otherwise. checkRetiredMarks refuses, at start, rebuild and prune, a retired type whose recorded marks give a field different categories that no such walk settled, so the category no longer depends on the order sets were first recorded in.
… whatever person other sets named A retired type's field marked for different person fields and in different categories no longer refuses the start once a walk sealed every value under a set that marks it. A value left in the clear takes that set's category and the person it names; one whose event names somebody else stays in the clear, as that walk left it, and what other sets sealed keeps its person.
…since it read none running, and read the marks afresh where retired types are sealed A start takes its walk's lease before it reads the marks the store recorded, so a walk of other code that read none running records nothing after them. The lease is taken and renewed in a transaction, and a walk records its sets sealed in one that first checks no lease of other marks changed since its pass read them: transactions run one at a time on every adapter, so the two never interleave. StorageTransaction carries the checkpoint store for that. The walk, exports and redactions resolve a retired type's fields by the marks the store holds when they run, not those of the start, and the walk checks them again in the transaction that seals each person's events. Marks that no longer settle a retired type hold the walk with its error, refuse exports and redactions with the start's message, and the next start refuses.
… recorded keys in a category the app neither declares nor retires A category of bounda.personal-data.ts takes `retired: true` with its whole declaration: no field, call or decision marks it any more, its data keeps its retention and exemptions and is never forgotten at once, and the inventory and the exports say it is retired (formats: export 3, inventory 3, tenant export 10). The start, the prune with no app and the stranded listing refuse every category the store recorded keys in that the app neither declares nor retires, and build their rules per database from what it recorded, so a category recorded since stays one only newer code declares. A retired type whose recorded marks seal in such a category is refused too (EV2-aa). The start checks the marks before it records them, so a refused start records none.
…egister them from the generator `RetiredPersonalCategoryName` joins `PersonalCategoryName` wherever a category already stored is named: what forget, restrict and unrestrict take, and every forgetting, restriction, redaction, recipient and export that reaches one. `personal(...)`, `.personal(...)`, decisions and recipient declarations still take categories in use alone. The generator registers the retired names as `retiredPersonalCategories`, and the CLI's inventory marks a retired category.
…the stored event holds `RedactedFields.fields` offers the fields an event type marks now by name and takes any other. Every current event type and every lifecycle event that carries a process's state is a target, one that marks nothing now included. `redact` no longer refuses a field because its type does not mark it: it reaches each field by its envelope, as it does a retired type's, so a value sealed under an earlier mark is redacted. It refuses a field held in the clear the type does not mark now, one sealed for another person, one the event does not hold, and a stream and type the app knows nothing of, saying which.
…marks seal in a dropped category
…s targets stay assignable to RedactedFields
…he public types that take or report it
…e holds name when they are filed (EV2-ai) A delayed policy's dead letter and a subscriber's last failure named the person of a retired type's event by the sets of marks the start read. A walk of other code that caught up alone since may name another. Both now read the sets afresh; the letter's commit reads them again in its transaction, which runs one at a time with the one a walk records its sets sealed in, and seals the letter again when they name someone else. Policies and processes react to no retired type, so their letters never name one.
…retired, not declared only (EV2-ak) A forgetting, a restriction or a recipient notice may name a retired category; the casts that built their payloads said a declared one.
… end to end (EV2-al)
…t only those keys were added in (EV2-aj) A category only a restriction, a forgetting, a redaction, a disclosure, a recipient declaration or a forget ledger entry named could be dropped from bounda.personal-data.ts without retiring it, leaving stored writes that name a category the app no longer knows. - PersonalKeyStore.recordCategories records categories in the catalogue, in the caller's transaction (memory, SQL; fenced as a write). - Runtime events, disclosures and recipient declarations record the categories they name in the transaction that writes them; forget ledger entries record theirs before the ledger takes them. - The unreleased migration (SQLite v16, PostgreSQL v17) backfills the catalogue from runtime events, restrictions, disclosures, declared recipients and forgotten counts (fillNamedCategoriesStatements). - The refusal now reads "categories the store has recorded". BREAKING CHANGE: an adapter's PersonalKeyStore implements recordCategories.
…lope, and upgrade to 0.6.0 Changing events gains retiring an event type and what a start refuses, with every message. Personal data gains retiring a category, the recorded-categories refusal, sealing a retired type by recorded marks, redaction's five outcomes and the export, inventory and tenant-export versions. Adapters gain what an adapter of your own implements since 0.6.0; deployment, dead letters, conventions, CLI, errors, GDPR, limitations, read models and project layout follow.
… code neither declares nor retires A rebuild with no app checked the store's event types and the marks of its retired types as a start does, but not its recorded categories: code that dropped a category rebuilt where its start would be refused.
…efusal and recordCategories Widen what records a category to a key, restrictions and their lifts, forgettings, redactions, disclosures, recipient declarations and forget ledger entries; note that the migration records what stored writes name, so the first start after upgrading may refuse a category dropped earlier; and add PersonalKeyStore.recordCategories to an adapter of one's own and to the changeset.
…s, and drop the lease's unused checkpoint calls
…o event beside a retired one
…, the stored marks, the exports and the redaction targets Simplify three reads that could not change a result (a set's marks, an event type's openings, an event that names nobody), and keep a set that marks nothing as null in memory, as the SQL stores do.
…of an aggregate or process this code no longer has The settle of a redaction looked only at events whose type this code reaches, so an instance of earlier code that wrote an old value into a kind this code reads as stored left it sealed under the person's key, where the tenant export opens it. Reach every event of the person by its envelopes.
…ent of the person
… sealed, the hold's rest and resealing a retired type's events
…s, forgotten tenants, delayed runs, process letters and the unit of work's marks
@bounda-dev/cli
@bounda-dev/cloudflare
@bounda-dev/core
create-bounda
@bounda-dev/postgresql
@bounda-dev/react-router
@bounda-dev/sqlite
commit: |
…as Windows writes it with backslashes
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
PR 2 of schema evolution (0.6.0): event types and personal-data categories can be retired, and a redaction reaches fields by what the stored event holds.
export const retired = true. Folds skip it; its events are read as stored.bounda generaterefuses a retired module that exports anything else, an upcaster next to it, and a process handler, policy or projection named after it; boot refuses anon, a processconfigor acorrelatethat names it. A delayed policy run whose policy no longer handles its event's type is dropped and settled with a warning. A process's dead letter names the instance it failed in (instanceId).bounda forget-ledger pruneandbounda forget-ledger strandedrefuse a store holding events of a type of one of the app's aggregates that no module names, and a retired type whose events opened streams of an aggregate whose statebeginsets up.bounda_event_marks. The backfill seals what a retired type still holds in the clear by those marks; where sets disagree, the set a walk last sealed the whole store under with no instance on other marks running (sealed_through, read fresh) settles it. A retired type no start recorded marks for, whose marks seal in a category the file neither declares nor retires, or whose marks disagree with no such walk, is refused at start and again by the backfill, an export and a redaction. Failures and letters of a retired type are sealed for the person the marks the store holds name when they are filed.redactreaches any field of every event type, a retired type and a field no longer marked included, by what the stored event holds; the export and the tenant export follow the envelope too. Settling a redaction reaches an old value written after it in any event of the person, one of an aggregate or a process this code no longer has included.retired: true, keeping its whole declaration; it leavesPersonalCategoryName(RetiredPersonalCategoryNamenames it where it is still taken or reported). The store records every category a key was given in and every category a stored write names (restrictions and their lifts, forgettings of a person or a tenant, redactions, disclosures, recipient declarations, forget ledger entries); a start, a rebuild,pruneandstrandedrefuse a recorded category the file neither declares nor retires.Closes E12, E13, E14, E15, E16, E21, E32, E33, E34, E37 and E38.
Breaking changes
beginsets up, refuses the start, a rebuild,pruneandstranded(ConfigurationError). Retire the type, or keep its module.bounda.personal-data.tsneither declares nor retires refuses the start, a rebuild,pruneandstranded, forgetting nothing, where its keys were forgotten at once before. The migration records the categories the writes the store already holds name, so the first start after upgrading may refuse a category dropped earlier: retire it.ValidationErrorinstead of resolving without sealing anything.EventStoregainsrecordMarks,marksOfandrecordSealed;StoredEventTypegainsopened;StoredDeadLettergainsinstanceId;StorageTransactiongainscheckpointStore;PersonalKeyStoregainsrecordCategories. The contracts cover them.Gates
pnpm checkwith Docker running: exit 0 (407 files; 8482 tests passed, 60 skipped).pnpm test:coverage: exit 0 (lines 99.07%, statements 98.72%, functions 97.89%, branches 96.33%). The lines and branches thresholds are raised to 99.0 and 96.2.pnpm test:types: exit 0.pnpm docs:build: exit 0.core1522 killed, 5 timed out, 50 survived or not covered;cli122 killed, 2 survived;postgresql56 killed, 1 survived. Each remaining mutant is equivalent: a guard that only narrows a type or skips work that would give the same result, a fallback an earlier check makes unreachable, or a sort that only orders lock taking.Left for a separate PR
subscriberFailuresinStorageTransaction.